package com.lj.queue.result;

import com.lj.queue.entity.DelayQueueMeta;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * <p>
 * 延迟队列数据表 分页结果
 * </p>
 *
 * @author lj
 * @since 2025-07-18 17:15:03
 */
@Data
@Schema(description = "延迟队列数据表 分页结果")
public class DelayQueueMetaPageResult {

    @Schema(description = "主键id ")
    private Long id;

    @Schema(description = "队列名称 ")
    private String name;

    @Schema(description = "最后加载时间 ")
    private LocalDateTime lastLoadTime;

    @Schema(description = "预加载间隔 ")
    private Long preloadDistance;

    @Schema(description = "预加载时长 ")
    private Long preloadDuration;

    @Schema(description = "时间单位 参考字典: TimeUnits")
    private Integer timeUnit;

    public static DelayQueueMetaPageResult of(DelayQueueMeta entity) {
        if (entity == null) {
            return null;
        }
        DelayQueueMetaPageResult result = new DelayQueueMetaPageResult();
        result.setId(entity.getId());
        result.setName(entity.getName());
        result.setLastLoadTime(entity.getLastLoadTime());
        result.setPreloadDistance(entity.getPreloadDistance());
        result.setPreloadDuration(entity.getPreloadDuration());
        result.setTimeUnit(entity.getTimeUnit() != null ? entity.getTimeUnit().getValue() : null);
        return result;
    }
}
